<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const object = {
            age: 18,
            name: '椿',
            address: '江西',
            hobby: ['唱', '跳', 'rap', '打篮球'],
            ablity:{
                a:'吃饭',
                b:'睡觉',
                c:'打游戏',
            },
        }
        const newobject = {}
        function deepcopy(newobj, oldobj) {
            for (let k in oldobj) {
                if (oldobj[k] instanceof Array) {
                    newobj[k] = []
                    deepcopy(newobject[k], object[k])
                }
               else if (oldobj[k] instanceof Object) {
                    newobj[k] = {}
                    deepcopy(newobject[k], object[k])
                }
                else {
                    newobj[k] = oldobj[k]
                }
            }
        }
        deepcopy(newobject, object)
        newobject.hobby[0] = '升升级'
        console.log(newobject);
        console.log(object);

    </script>
</body>

</html>